package main

import (
	"fmt"
	"net"
	"strconv"
	"time"
)

func main() {
	conn, err := net.Dial("tcp", "localhost:8888")
	if err != nil {
		conn.Close()
	}
	defer conn.Close()
	count := 0
	for {
		msg := "hello:" + strconv.Itoa(count)
		write, err := conn.Write([]byte(msg))
		if err != nil {
			fmt.Println("发送数据失败:", err)
			break
		}
		if write > 0 {
			fmt.Println("send msg:", msg)
		}
		time.Sleep(time.Second)
		count++
	}
}
